package GameLogic
{
	import BasicEngine.Vector2D;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	public class CompleteRadar extends Sprite
	{
		public var Clr:int;
		public var Len:int ;
		public var Angle:Vector2D;
		public var Hide:Boolean;
		/**
		 * 顺时针
		 */
		public var CW:Boolean;
		/**
		 * 转速
		 */
		public var Rev:Number;
		public var MaxAngle:Number = 180;
		public var MinAngle:Number = -180;
		public var Speed:Number;
		
		private var shape:Shape;
		private var maskt:Shape;
		private var timer:Number;
		
		
		public function CompleteRadar(_clr:int = 0x00ff00,_len:int= 250,_rev:Number = 0.1,_alpha:Number = 0.5)
		{
			Clr = _clr;
			Len = _len;
			Rev = _rev;
			shape = new Shape();
			CW = true;
			for (var i:int = 0; i < 30; i++)
			{
				shape.graphics.lineStyle(2, Clr,i*0.05);
                shape.graphics.moveTo(0, 0);
                shape.graphics.lineTo(Len*2, i*3);
			}
			this.alpha = _alpha;
			Angle = new Vector2D(1, 1).Normalize();
			Hide = false;
			addChild(shape);
			
			maskt = new Shape();
			maskt.graphics.beginFill(0xff0000, 1);
			maskt.graphics.drawCircle(0, 0, Len);
			
			shape.mask = maskt;
			addChild(maskt);
			
			this.addEventListener(Event.ENTER_FRAME, Update);
		}
		
		public function SetAngle(_min:Number, _max:Number):void
		{
			MinAngle = _min;
			MaxAngle = _max;
		}
		
		public function Update(e:Event):void
		{
		    if (Game.Pause || Hide)
				return;
			shape.rotation = Angle.Angle * 180 / Math.PI;
			 
			//if (CW)
			   //Angle.Angle += Rev;
			//else
			Angle.Angle -= Rev;
			   //
			//if (shape.rotation > MaxAngle)
			  //CW = false;
			//else if (shape.rotation < MinAngle)
			  //CW = true;
			
		}
		
	}
}